/*
* @Author: liyanweiofwin
* @Date:   2017-06-18 17:11:16
* @Last Modified by:   liyanweiofwin
* @Last Modified time: 2017-06-18 17:51:27
*/

'use strict';
require('./index.css');

var _mm = require('util/mm.js');

var header = {
	init : function(){
		 this.bindEvent();
		// this.loadUserInfo();
		// this.loadCardCount();
	},
	onLoad : function(){
		var kayword = _mm.getUrlParam('keyword');
		if (keyword) {
			$('#search-input').val(keyword);
		}
	},


	bindEvent :function(){
		var _this = this;
		$('#search-btn').click(function(){
			_this.searchSubmit();
		});
		$('#search-input').keyup(function(e){
			if (e.keyCode === 13) {
				_this.searchSubmit();
			}
		});
	},
	searchSubmit : function(){
		var	keyword = $.trim($('#search-input').val(keyword));
		if (keyword) {
			window.location.href = './list.html?keyword='+ keyword;
		}else{
			_mm.goHome();
		}
	}
};

header.init();